//
//  XYJoinMeetingViewController.m
//  NemoSDKDemo
//
//  Created by 高超 on 2020/7/29.
//  Copyright © 2020 JackYang. All rights reserved.
//

#import "XYJoinMeetingViewController.h"
#import "XYMeetingViewController.h"
#import "XYAlertView.h"

@interface XYJoinMeetingViewController ()
@property (weak, nonatomic) IBOutlet UITextField *meetingNumberTF;
@property (weak, nonatomic) IBOutlet UIButton *joinMeetingBtn;
@property (weak, nonatomic) IBOutlet UISwitch *cameraSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *microphoneSwitch;

@end

@implementation XYJoinMeetingViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self _setupSubView];
    
//    [[XYSDKManager sharedInstance] create];
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

#pragma mark private function
- (void)_setupSubView {
    self.cameraSwitch.transform = CGAffineTransformMakeScale(44.0/self.cameraSwitch.bounds.size.width, 24.0/self.cameraSwitch.bounds.size.height);
    self.microphoneSwitch.transform = CGAffineTransformMakeScale(44.0/self.cameraSwitch.bounds.size.width, 24.0/self.cameraSwitch.bounds.size.height);
    self.joinMeetingBtn.layer.cornerRadius = self.joinMeetingBtn.bounds.size.height/2.f;

}

#pragma mark IBAction

- (IBAction)cameraSwitchAction:(id)sender {
    UISwitch *sw = (UISwitch *)sender;
    [XYSDKManager sharedInstance].muteVideo = sw.isOn;
}

- (IBAction)microphoneSwitchAction:(id)sender {
    UISwitch *sw = (UISwitch *)sender;
    [XYSDKManager sharedInstance].muteAudio = sw.isOn;
}

- (IBAction)joinMeetingAction:(id)sender {
    if (_meetingNumberTF.text.length == 0) {
        [XYHUDManager showBriefToast:@"请输入会议号"];
        return;
    }
    [[XYSDKManager sharedInstance] joinMeeting:_meetingNumberTF.text password:nil];
//    TabbarController *tab = (TabbarController *)self.tabBarController;
//    [tab showMeetingUI];
}
- (IBAction)tapViewAction:(id)sender {
    [self.meetingNumberTF resignFirstResponder];
}

@end
